package com.bjwl.web.contrlller.branchstore;

import com.bjwl.pojo.Bsadmin;
import com.bjwl.pojo.CardStrip;
import com.bjwl.pojo.Staff;
import com.bjwl.service.NannyService;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author: czc
 * @Date:Create：in 2020/5/20 15:52
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/nanny")
public class NannyController {

    @Autowired
    private NannyService nannyService;



    @RequestMapping("/findAllNannyPage")
    public String findAllNannyPage(HttpSession httpSession, HttpServletRequest request,  Integer pageNum , Float nhourse) {
        if(pageNum == null){
            pageNum =1;
        }
        Bsadmin bsadmin1 = (Bsadmin) httpSession.getAttribute("bsadmin1");
        Integer bsid = bsadmin1.getBsid();
        PageBean<Staff> staffNannyList = nannyService.findAllNannyPage(pageNum,bsid ,nhourse);
        request.setAttribute("staffNannyLists", staffNannyList);
        request.setAttribute("nhourse",nhourse);
        return "branch_oa/staffinfo_list";

    }


    @RequestMapping("/jumpShowNunny")
    public String jumpShowNunny(Integer id ,Model model){
        Staff staff = nannyService.findNannyById(id);
        model.addAttribute("staff",staff);
        return "branch_oa/staffinfo";
    }

    @RequestMapping("/findAllCleaningPage")
    public String findAllCleaningPage(HttpSession httpSession, HttpServletRequest request,  Integer pageNum , String  sremark) {
        if(pageNum == null){
            pageNum =1;
        }
        Bsadmin bsadmin1 = (Bsadmin) httpSession.getAttribute("bsadmin1");
        Integer bsid = bsadmin1.getBsid();
        PageBean<Staff> staffCleaningList = nannyService.findAllCleaningPage(pageNum, bsid ,sremark);
        request.setAttribute("staffCleaningLists", staffCleaningList);
        request.setAttribute("sremark",sremark);
        return "branch_oa/staffinfo_list_Cl";

    }

    @RequestMapping("/jumpShowCleaning")
    public String jumpShowCleaning(Integer id ,Model model){
        Staff staff = nannyService.findNannyById(id);
        model.addAttribute("staff",staff);
        return "branch_oa/staffinfo";
    }


}
